package collection;

import java.util.*;

public class CollectionsSort {
    public static void main(String[] args) {

        List<String> context = Arrays.asList("b","z","a","c","e","g","n");
        Collections.sort(context);
        System.out.println(Arrays.toString(context.toArray()));
        List<String> context1 = Arrays.asList("1","2","3","a","5","6","7");

        // 如果两个集合中存在 相同的元素 返回false，如果存在相同的元素，则返回true
        boolean disjoint = Collections.disjoint(context1, context);
        System.out.println(disjoint);




        List<User> users = new ArrayList<>();
        for (int i = 0;i<10;i++){
            User user = new User();
            user.setName("zhangsan"+i);
            Random random = new Random();
            user.setAge(random.nextInt(100));
            users.add(user);
        }



        Collections.sort(users, new Comparator<User>() {
            @Override
            public int compare(User o1, User o2) {
                return o1.getAge()-o2.getAge();
            }
        });
        for (User user : users) {
            System.out.println(user.getName()+":"+user.getAge());
        }

    }
}
